#pragma once

namespace SD_Tools
{
	class TexManager
	{
	private:
		SimpleTree<DWORD>* TextureTree;
		IDirect3DDevice9* Device;
	public:
	private:
	public:
		TexManager(IDirect3DDevice9* Device);
		DWORD GetCRC(IDirect3DTexture9* Texture);
		void Reset();
	};

	TexManager::TexManager( IDirect3DDevice9* Device )
	{
		TextureTree = new SimpleTree<DWORD>();
		this->Device = Device;
	}

	DWORD TexManager::GetCRC( IDirect3DTexture9* Texture )
	{
		DWORD CRC;
		if (!TextureTree->GetData((DWORD)Texture, &CRC))
		{
			if (!DirectXHelper::GenerateTextureCRC32(Device, Texture, &CRC))
			{
				TextureTree->AddNode((DWORD)Texture, 0x00000000);
				CRC = 0x00000000;
			}
			TextureTree->AddNode((DWORD)Texture, CRC);
		}
		return CRC;
	}

	void TexManager::Reset()
	{
		TextureTree->Clear();
	}

}



















